<%@ page language="java"  contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"  %>
<%@include file="inc/comm.jsp" %>
<%@include file="inc/inc_head.jsp" %>
<html>
<head>
    <meta charset="utf-8"/>
    <title>首页</title>
    <link href="${ctx}/resources/style/share.css" rel="stylesheet" type="text/css" />
    <link href="${ctx}/resources/style/index.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
    <div class="logo">
        <div class="logo-left">质量管理体系文件</div>
        <%--<div class="logo-right"></div>--%>
        <%--<div class="clear"></div>--%>
        <%--<div class="logo-right">--%>
            <%--<ul class="nav ace-nav nav1">--%>
                <%--<li>--%>
                    <%--<a data-toggle="dropdown" href="${ctx}/" class="dropdown-toggle">--%>
                        <%--<img class="nav-user-photo" src="${ctx}/resources/avatars/user.jpg" alt="Jason's Photo"/>--%>
								<%--<span class="user-info">--%>
									<%--<small>欢迎光临</small>--%>
                                    <%--<strong id="username">${username}</strong>--%>
								<%--</span>--%>
                        <%--<i class="arrow fa fa-caret-down"></i>--%>
                    <%--</a>--%>
                    <%--<ul class="user-menu pull-right dropdown-menu dropdown-yellow dropdown-caret dropdown-close">--%>
                        <%--<li>--%>
                           <%--<a href="${pageContext.request.contextPath}/logout">--%>
                                <%--<i class="fa fa-power-off"></i>--%>
                                <%--退出--%>
                           <%--</a>--%>
                        <%--</li>--%>
                        <%--&lt;%&ndash; <li class="divider"></li>&ndash;%&gt;--%>
                    <%--</ul>--%>
                <%--</li>--%>

            <%--</ul>--%>
            <%--<!-- /.ace-nav -->--%>
        <%--</div>--%>
    </div>


    <div class="nav">
        <a href="#" name="1" onclick="jump(this)" class="index" id="first">体系首页</a>
        <a href="#" name="2" onclick="jump(this)" class="system" id="system">公司制度</a>
        <a href="#" name="3" onclick="jump(this)" class="role" id="role">业务角色</a>
        <a href="#" name="4" onclick="jump(this)" class="flow" id="flow">业务流程</a>
        <a href="${ctx}/info" name="5" onclick="addIframe(this); return false;" class="searchquick" id="searchquick">快速搜索</a>
        <a href="#" name="6" onclick="jump(this)" class="link" id="link">相关链接</a>
        <a href="#" name="7" onclick="jump(this)" class="scrum" id="scrum">敏捷（Scrum）开发</a>
        <a href="#" name="8" onclick="jump(this)" class="env" id="env">环境体系</a>
        <a href="#" name="9" onclick="jump(this)" class="info" id="info">信息安全</a>
    </div>
</div>
<div class="content">
    <div class="left" id="left" style=" background:#f9f9f9;">
       <%--二级菜单--%>
        <ul id="index">
            <c:forEach items="${list}" var="item">
                <li>
                    <a href="<c:if test="${empty item.url}">${ctx}/upload?parentId=${pid}&secondId=${item.id}&name=${item.name}</c:if><c:if test="${not empty item.url}">${ctx}${item.url}</c:if>"
                       id="${pid}${item.id}" name="${item.id}" title="${item.name}"
                       onclick="secondIframe(this);return false;">${item.name}</a>
                    <%--三级菜单--%>
                    <ul class="tindex" id="tindex${item.id}">
                        <c:forEach items="${item.tlist}" var="it">
                            <li>
                                <a href="<c:if test="${empty it.url}">${ctx}/upload?parentId=${pid}&secondId=${item.id}&thirdId=${it.id}&name=${it.name}</c:if><c:if test="${not empty it.url}">${ctx}${it.url}</c:if>"
                                   name="${it.id}" id="${pid}${item.id}${it.id}" class="${item.id}" title="${it.name}"
                                   onclick="thirdIframe(this);return false;">${it.name}</a>
                            </li>
                        </c:forEach>
                            <%--三级菜单添加--%>
                    </ul>
                </li>
            </c:forEach>
        </ul>
    </div>
    <div class="right" id="right" style="border-left:1px solid #e5e5e5 !important;">
        <iframe src="${ctx}/home" name="content" id="content" style="border: none; overflow-y:visible; overflow-x:hidden;"
                width="100%" >
        </iframe>

    </div>
</div>

</body>
<script type="text/javascript">

    /*一级菜单跳转*/
    function jump(obj){
        $('#addMenu').attr('name', $(obj).attr('class'));
        $('#add_tmenu').attr('name', $(obj).attr('class'));
        var name = $(obj).attr("name");
        $(obj).attr("href","${ctx}/index?pid="+name);
    }
    /*一级菜单跳转*/

    function thirdIframe(obj){
        var url=$(obj).attr('href');
        var name=$(obj).attr('title');
        var secondId=$(obj).attr('class');
        var thirdId=$(obj).attr('name');
        if(url=='' || url=='###'){
            $('#content').attr('src', '');
            $('#content').attr('src', '${ctx}/upload?parentId=${pid}&name='+name+'&secondId='+secondId+'&thirdId='+thirdId);
        }else{
            $('#content').attr('src', '');
            var _href = $(obj).attr('href');
            $('#content').attr('src', _href);
        }

    }



    function secondIframe(obj) {
        var dis=$(obj).parent().find('.tindex').css('display');
        if(dis=='none'){
            $(obj).parent().find('.tindex').css('display','block');
        }else{
            $(obj).parent().find('.tindex').css('display','none');
        }
        var url=$(obj).attr('href');
        var name=$(obj).attr('title');
        var id=$(obj).attr('name');

        if(url=='' || url=='###'){
            $('#content').attr('src', '');
            $('#content').attr('src', '${ctx}/upload?parentId=${pid}&name='+name+'&secondId='+id);
        }else{
            $('#content').attr('src', '');
//            var _href = $(obj).attr('href');
            $('#content').attr('src', url);
        }

        return false;
    }


    /* 获取iframe可视区域高度 */
    function refreshContentHeight() {
        var frame = document.getElementById('content');
        var contentHeight = $(window).height() -155;
        frame.setAttribute('height', contentHeight);
        var left=document.getElementById('left');
        left.setAttribute('height', contentHeight);
    }

    $(function () {
        refreshContentHeight();
        $('.tindex').each(function(){
            $('.tindex').css('display','none');
        });

        var pid=${pid};
        var type = new Array('first', 'system', 'role', 'flow', 'searchquick','link', 'scrum', 'env', 'info');
        if(pid!='' && pid!=null){
            var ppid=parseInt(pid);
            $('#'+type[pid-1]).addClass('active');
        }else{
            $('#first').addClass('active');
        }

        $(window).resize(function () {
            refreshContentHeight();
            $("#sidebar").css("height", $(window).height() - 70 + "px");
            /* $(".slimScrollDiv").css("height", $(window).height() - 20 + "px");*/
        });

        $("#content").load(function () {
            refreshContentHeight();
        });
    });


    function addIframe(obj){
        $(obj).addClass('active');
        var type = new Array('first', 'system', 'role', 'flow', 'link', 'scrum', 'env', 'info');
        for(var i=0;i<type.length;i++){
            $('#'+type[i]).removeClass('active');
        }
        $('#content').attr('src', '');
        var _href = $(obj).attr('href');
        $('#content').attr('src', _href);
    }

</script>

</html>
